package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	// 订单操作记录
	type TripRiderLog struct {
		models.BaseModel

		TripRiderId uint64 `gorm:"column:trip_rider_id;comment:行程-乘客订单表id;" db:"trip_rider_id" json:"trip_rider_id" form:"trip_rider_id"` //订单ID
		Action      string `gorm:"type:varchar(255);comment:行为比如修改行程，修改价格等;" db:"action" json:"action" form:"action"`                     //行为：比如修改行程，修改价格等
		UserType    uint8  `gorm:"column:user_type;comment:行为人类型 1司机 2乘客;" db:"user_type" json:"user_type" form:"user_type"`              //行为人类型1：司机，2：乘客
		Log         string `gorm:"column:log;comment:行为内容代码中自定义结构;" db:"log" json:"log" form:"log"`                                       //行为内容，代码中自定义结构

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&TripRiderLog{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&TripRiderLog{})
	}

	migrate.Add("2023_07_18_142327_add_trip_rider_logs_table", up, down)
}
